package pub.wkq.springframework.context.support;

import pub.wkq.springframework.beans.BeansException;
import pub.wkq.springframework.beans.factory.ConfigurableListableBeanFactory;
import pub.wkq.springframework.beans.factory.support.DefaultListableBeanFactory;
import pub.wkq.springframework.core.io.DefaultResourceLoader;

import java.util.Map;

/**
 * @author 21129
 */
public abstract class AbstractRefreshableApplicationContext extends AbstractApplicationContext{
    private DefaultListableBeanFactory beanFactory;

    @Override
    protected void refreshBeanFactory() throws BeansException {
        DefaultListableBeanFactory beanFactory = createBeanFactory();
        loadBeanDefinitions(beanFactory);
        this.beanFactory = beanFactory;
    }

    protected abstract void loadBeanDefinitions(DefaultListableBeanFactory beanFactory);


    private DefaultListableBeanFactory createBeanFactory() {
        return new DefaultListableBeanFactory();
    }

    @Override
    public ConfigurableListableBeanFactory getBeanFactory() {
        return beanFactory;
    }
}
